<template>
<!-- 这是主页 -->
  <div id="website">
    <link href="https://cdn.jsdelivr.net/npm/animate.css@3.5.1" rel="stylesheet" type="text/css">
    
    <div class="website_content">
      <div class="website_logo">
        <topLogo></topLogo>
      </div>
      <!-- <h3><router-link to="/Case">案例</router-link></h3>
      <h3><router-link to="/Partner">合作商</router-link></h3> -->
      <div :class="['BeforeRefreshLeft' , 'content_title', classBool ? 'AfterRefresh': '']">
        <div class="website_title">WELCOME TO</div>
        <!-- 打字机 -->
        <div class="text">{{strtext}}</div>
      </div>
      <div class="content_middle">
        <div class='content_swipe'>
          <div :class="['content_seat', 'BeforeRefreshRight', classBool ? 'AfterRefresh': '']">
            <div :class="['swipe_text', current == 0 ? 'effect': '']">
              <!-- <h4>建材</h4> -->
              <p>其米装饰是一家集设计、施工、家居定制、服务于一体的综合服务型公司</p>
              <p>Qimi company provides design, construction, furniture customization in one integrated service company</p>
            </div>
            <div :class="['swipe_text', current == 1 ? 'effect': '']">
              <!-- <h4>家具</h4> -->
              <p>AFORM公司以建筑设计为龙头，涵盖城市规划及室内设计，提供各种类型建筑设计业务</p>
              <p>Aform focuses on architectural design，Including urban planning and interior design, Provide various types of architectural design.</p>
            </div>
            <div :class="['swipe_text', current == 2 ? 'effect': '']">
              <!-- <h4>设计师</h4> -->
              <p>筑和智建 我们为你臻选最有特色、最好玩、最新奇的建筑整装产品和建筑氛围艺术品</p>
              <p>Zhijian company provide you with the most special, the most fun, the most novel architectural decoration products and architectural works of art</p>
            </div>
            <div :class="['swipe_text', current == 3 ? 'effect': '']">
              <!-- <h4>施工团队</h4> -->
              <p>城拓设计拥有国家建筑工程设计乙级和风景园林工程设计专项乙级资质</p>
              <p>Chengtuo Design has the qualification of National Building Engineering Design and Landscape Architecture Engineering Design.</p>
            </div>
            <div class="custom-indicator">
              {{ current + 1 }}/4
            </div>
          </div>
          <router-link to="/Project" :class="[classBool ? 'lengthen': '', cover ? 'noneLength': '']"><div class="button">查看项目 PROJECT</div></router-link>
        </div>
      </div>
      <!-- 介绍 -->
      <div class="article">
        <div class="article_content" v-for="item in dataArr" :key="item.id">
          <div class="aform animated fadeInDown"><span>AFORM</span></div>
          <h5 class="animated fadeInLeft">{{item.name}}</h5>
          <p class="animated fadeInLeft">{{item.introduce}}</p>
        </div>
        <router-link to="/Project" :class="[classBool ? 'lengthen': '', cover ? 'noneLength': '']"><div class="button">查看项目 PROJECT</div></router-link>
      </div>
      <div class="tab">
        <router-link to="/details">
          <div class="tab_img">
            <img src="./../../../public/img/kEOB14UDm8UZS1buuAb4u1oaM6Uy11.gif" alt="">
            <div class="tab_text">
              <span>光影流年</span>
              <p>Time of light and shadow</p>
            </div>
          </div>
        </router-link>
        <router-link to="/details">
          <div class="tab_img">
            <img src="./../../../public/img/ztX7OHc7Oo8p8L88Hcx8zaAs8AaaA8.jpg" alt="">
            <div class="tab_text">
              <span>蓝色浪漫</span>
              <p>Blue Romance</p>
            </div>
          </div>
        </router-link>
        <router-link to="/details">
          <div class="tab_img">
            <img src="./../../../public/img/m6315Tnaz19xqQPBxXKZpB1qI6KlfO.jpg" alt="">
            <div class="tab_text">
              <span>高山流水</span>
              <p>Mountains and rivers</p>
            </div>
          </div>
        </router-link>
      </div>
      <div class="project">
        <div class="project_title">
          <div class="aform animated fadeInDown"><span>AFORM</span></div>
          <h4>项目表<span>Project table</span></h4>
        </div>
        <div :class="['entryName', projectBool ? 'showProject': '']">
          <ul>
            <router-link to="/project"><li>吊装建筑酒店<span>PROJECT</span></li></router-link>
            <a href="http://www.aform-design.com/detail?p=52"><li>寻梅酒店<span>PROJECT</span></li></a>
            <a href="http://www.aform-design.com/detail?p=52"><li>中鑫时代广场项目<span>PROJECT</span></li></a>
            <a href="http://www.aform-design.com/detail?p=52"><li>新城市·领秀<span>PROJECT</span></li></a>
            <a href="http://www.aform-design.com/detail?p=52"><li>广州番禺草堂项目<span>PROJECT</span></li></a>
            <a href="http://www.aform-design.com/detail?p=52"><li>五矿哈施塔特<span>PROJECT</span></li></a>
            <a href="http://www.aform-design.com/detail?p=52"><li>吊装建筑酒店<span>PROJECT</span></li></a>
            <a href="http://www.aform-design.com/detail?p=52"><li>吊装建筑酒店<span>PROJECT</span></li></a>
            <a href="http://www.aform-design.com/detail?p=52"><li>吊装建筑酒店<span>PROJECT</span></li></a>
            <a href="http://www.aform-design.com/detail?p=52"><li>吊装建筑酒店<span>PROJECT</span></li></a>
            <router-link to="/project"><li>吊装建筑酒店<span>PROJECT</span></li></router-link>
          </ul>
        </div>
        <div class="showMore">
          <span @click="more">{{moreText}}</span>
        </div>
      </div>
      <div class="local">
        <h5>我们期待与你沟通</h5>
        <span>We are expect to communicate with you</span>
        <div class="address">
          <van-icon name="location-o" color="black" />
          <p>ADDRESS</p>
          <span>广州市番禺区福景路917号</span>
        </div>
        <div class="phone">
          <van-icon name="phone-o" color="black" />
          <p>PHONE</p>
          <span>
            020-31360103<br/>
            400-0310-103
          </span>
        </div>
      </div>
    </div>
    
  </div>
</template>

<script>
import topLogo from "../../components/topLogo";
export default {
  data () {
    return {
      strtext: 'BUILDING MATERIAL',  //打字机
      current: 0, //轮播图指示器
      classBool: false, //是否添加类名
      cover: false, //添加没有延时类名
      dataArr: [],  //渲染数据
      projectBool: false, //显示更多项目添加类名
      moreText: '查看更多',
    }
  },
  components: {
    topLogo
  },
  methods: {
    // 打字机
    typewriter() {
      var _this = this;
      let i = 0;
      let str = [];
      str[0] = 'BUILDING MATERIAL';  //要打印的文字
      str[1] = 'FURNITURE';  //要打印的文字
      str[2] = 'DESIGNER';  //要打印的文字
      str[3] = 'CONSTRUCTION TEAM';  //要打印的文字
      let timer = setInterval( () => {
        if (i <= str[_this.current].length) {
          _this.strtext = str[_this.current].slice(0, i++);
        }
        else {
          _this.strtext = str[_this.current]; //结束打字,移除 | 光标
          clearInterval(timer);  //清除计时器
        }
      }, 100);  //打一个字的时间
      
    },
    // 轮播内容
    Interval() {
      var _this = this;
      let num = 0;
      var intTimer = setInterval( () => {
        if (num < 3) {
          num += 1;
          _this.current = num;
        }
        else {
          num = 0;
          _this.current = num;
        }
        _this.typewriter();
      }, 4000);  //轮播时间
      // 切换到别的页面的时候，清除定时器，回来的时候开启。
      document.onvisibilitychange = function(){
        if(document.visibilityState == "visible"){   
            intTimer = setInterval( () => {
              if (num < 3) {
                num += 1;
                _this.current = num;
              }
              else {
                num = 0;
                _this.current = num;
              }
              _this.typewriter();
            }, 4000);  //轮播时间
        }else{       
          clearInterval(intTimer);
        }
      }
    },
    // 添加动画效果
    // effect() {
    //   this.classBool = true;
    // },
    // 显示更多项目
    more() {
      this.projectBool = this.projectBool ? false : true;
      this.moreText = this.moreText == '查看更多' ? '隐藏' : '查看更多';
    }
  },
  created () {
    var _this = this;

    let ids = _this.$route.query.id;
    if(ids == undefined) {
      ids = 1;  //我们自己的页面，优粤家
    }
    _this.$store.commit('MerchantID', ids);

    _this.$get(`company/${ids}`
    ).then(res => {
      if(res.code == 200) {
        res.data[0].logo = res.data[0].logo.replace(/images\//g, 'https://uekea-1257881260.cos.ap-guangzhou.myqcloud.com/images/');
        _this.dataArr = res.data;
        _this.$store.commit('logo', res.data[0].logo);
      }
    }).catch(() => {
      console.log('数据异常');
    })
  },
  mounted () {
    this.Interval();
    this.classBool = true;
    setTimeout(()=> {
      this.cover = true;
      // this.classBool = false;
    },2100);
    // setTimeout
  },
  // beforeMount() {
  //   var _this = this;
  //   setTimeout(function() {
  //     _this.effect();  //添加动画类名
  //   },20)
  // },
  beforeDestroy() {
    this.classBool = false; //去掉添加动画类名
    this.projectBool = false; //去掉显示更多类名
  },
}
</script>

<style lang="less" scoped>
.website_logo {
  margin-bottom: 50px;
}
.website_title {
  padding: 10px 30px;
  padding-bottom: 0px;
  font-size: 35px;
  text-align: left;
  font-weight: 600;
}
h1 {
  font-size: 28px;
}
.content_title {
  text-align: center;
  margin-bottom: 30px;
  font-size: 30px;
}
.content_seat {
  position: absolute;
  top: 0px;
  left: 0px;
  width: 100%;
  height: 350px;
  overflow: hidden;
  
}
.swipe_text {
  position: absolute;
  top: 0px;
  left: 0px;
  color: #555;
  line-height: 27px;
  padding: 20px 30px;
  font-size: 14px;
  height: 100%;
  opacity: 0;
  transition-duration: 1s;
  transform: translate3d(0,0,0);
  
}
// 添加透明度1
.effect {
  opacity: 1;
  transition-duration: 1s;
}
// 刷新的时候添加的动画
.BeforeRefreshLeft {
  opacity: 0;
  transition-duration: 1.5s;
  transform: translateX(-250px) !important; //从左边出
}
.BeforeRefreshRight {
  opacity: 0;
  transition-duration: 1.8s;
  transform: translateX(250px) !important; //从右边出
}
.BeforeRefreshTop {
  transition-duration: 1.5s;
  transform: translateY(-100px) !important; //从下面出
  opacity: 0;
}
.AfterRefresh {
  opacity: 1;
  transition-duration: 1.5s;
  transform: translateX(0px) !important;  //回原位
}
// 1.7s后开始
.AfterRefreshDelayed1 {
  opacity: 1 !important;
  transition-duration: 1.5s !important;
  transition-delay: 1s !important;
  transform: translateX(0px) !important;  //回原位
}
.AfterRefreshDelayed2 {
  opacity: 1 !important;
  transition-duration: 1.5s !important;
  transition-delay: 1.5s !important;
  transform: translateX(0px) !important;  //回原位
}
.AfterRefreshDelayed3 {
  opacity: 1 !important;
  transition-duration: 1.5s !important;
  transition-delay: 2s !important;
  transform: translateX(0px) !important;  //回原位
}
// 刷新的时候添加的动画，结束

// 轮播图指示器
.custom-indicator {
  position: absolute;
  right: 20px;
  bottom: 10px;
  padding: 2px 5px;
  font-size: 14px;
}
.content_swipe {
  position: relative;
  height: 350px;
  transform: translate3d(0,0,0);
  a {
    display: inline-block;
    position: absolute;
    bottom: 60px;
    left: 60px;
    transition:width 0.8s;
    -webkit-transition:width 0.8s;
    width: 50px;
    overflow: hidden;
    height: 50px;
    line-height: 50px;
    border: 1px solid #333;
    text-align: center;
    opacity: 0;
  }
  // 按钮长度过渡
  .lengthen {
    width: 230px;
    opacity: 1;
  }
  .button {
    font-size: 14px;
  }
}

.text {
  color:#333;
  height: 40px;
  text-align: left;
  padding: 0px 30px;
  font-size: 26px;
}
// 光标
.text:after {
  content: "";
  display: inline-block;
  height: 31px;
  width: 1px;
  background-color: #333;
  position: relative;
  top: 4px;
  -webkit-animation: blink-animation step-end 1s infinite;
  animation: blink-animation step-end 1s infinite;
}
@keyframes blink-animation {
  50% {background-color: transparent;}
}
.aform {
  font-size: 13px;
  margin-bottom: 10px;
  letter-spacing: 14px;
}
.article {
  padding: 20px 30px;
  margin-top: 60px;
  .article_content {
    line-height: 27px;
    color: #555;
    font-size: 14px;
    
    h5 {
      font-size: 20px;
      font-weight: 100;
      letter-spacing: 5px;
      margin-bottom: 30px;
    }
  }
  a {
    display: inline-block;
    width: 50px;
    overflow: hidden;
    height: 50px;
    line-height: 50px;
    border: 1px solid #333;
    text-align: center;
    margin-top: 30px;
    margin-left: 30px;
    opacity: 0;
  }
  // 按钮长度过渡
  .lengthen {
    width: 230px;
    opacity: 1;
    transition-duration: 0.8s;
    transition-delay: 1.2s;
  }
  .button {
    font-size: 14px;
  }
}
.noneLength {
  width: 230px !important;  
  opacity: 1 !important;
  transition-delay: 0s !important;
  transition-duration: 0s !important;
}

.tab {
  margin-top: 80px;
  font-size: 0px;
}
.tab_img {
  position: relative;
  img {
    width: 100%;
  }
  .tab_text {
    font-size: 22px;
    position: absolute;
    width: 100%;
    text-align: center;
    top: 30%;
    z-index: 1;
    color: rgba(255, 255, 255, 0.9);;
    
    p {
      font-size: 14px;
      margin-top: 10px;
    }
  }
}
.more {
  font-size: 14px;
  text-align: center;
  margin-top: 30px;
  overflow: hidden;
  a {
    display: inline-block;
  }
  p {
    display: inline-block;
    width: 150px;
    height: 45px;
    line-height: 45px;
    text-align: center;
    border: 1px solid #333;
  }
}
.tab_img::after {
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
  background-color: rgba(0,0,0,0.3);
  top: 0px;
  left: 0px;
}
.tab_img::after:hover {
  opacity: 0;
}
.local {
  margin-top: 90px;
  font-size: 14px;
  text-align: center;
  padding-bottom: 70px;
  color: #323232;
  h5 {
    font-size: 20px;
    font-weight: 100;
    margin-bottom: 8px;
  }
  .address {
    margin: 30px 0px;
    p {
      margin: 8px 0px;
    }
    .van-icon-location-o {
      font-size: 25px;
    }
  }
  .phone {
    margin-top: 30px;
    p {
      margin: 8px 0px;
    }
    .van-icon-phone-o {
      font-size: 25px;
    }
  }
}
a:link { 
  color:#333;
}
a:active {
  background-color:#ccc !important;
  color: white;
}
a:hover { 
  background-color:#ccc !important;
  color: white;
} 
a:visited {
  color:#333;
}
.project {
  padding: 20px 30px;
  margin-top: 90px;
  .project_title {
    color: #444;
    h4 {
      font-weight: 100;
      margin-top: 15px;
      span {
        font-size: 15px;
        margin-left: 10px;
      }
    }
  }
  .entryName {
    font-size: 15px;
    border-top: 1px solid #666;
    padding-top: 20px;
    margin-top: 50px;
    color: #333;
    max-height: 150px;
    transition-duration: 1s;
    overflow: hidden;
    ul {
      a {
        display: block;
      }
      li {
        line-height: 30px;
        span {
          color: #999;
          font-size: 12px;
          margin-left: 5px;
        }
      }
    }
  }
  .showMore {
    margin-top: 20px;
    font-size: 15px;
    span {
      padding-top: 10px;
      border-top: 1px solid #555;
    }
    span:hover {
      cursor: pointer;
    }
  }
}
// 显示更多项目
.showProject {
  max-height: 500px !important;
  transition: max-height 1.2s ease !important;
}

// 视频测试
.tab_img0 {
  width: 100%;
  video {
    width: 100%;
  }
}
</style>
